#ifndef DEF_H
#define DEF_H

#include "stdlib.h"
#include "stdio.h"
#include "string.h"
#include "png.h"

#define ERR_IFILE            1
#define ERR_OFILE            2
#define ERR_MEMALLOC         3
#define ERR_READPNG_INIT     11
#define ERR_WRITEPNG_INIT    21
#define ERR_WRITEPNG_HEADER  22
#define ERR_WRITEPNG_BODY    23
#define ERR_WRITEPNG_END     24

typedef struct spng {
    /* meta png size information */
    long width;
    long height;
    long aspect_ratio_w;
    long aspect_ratio_h;

    /* meta png content information */
    int color_type;
    int bit_depth;
    int channels;
    unsigned long rowbytes;
    unsigned char* image_data;
    png_bytep *row_pointers;

    /* background information */
    unsigned char bg_r;
    unsigned char bg_g;
    unsigned char bg_b;

    /* originating file */
    FILE *png_file;
    char *png_filename;
} spng;

extern png_structp png_ptr;
extern png_infop info_ptr;

extern unsigned int width;
extern unsigned int height;
extern int bit_depth;
extern int color_type;
extern double LUT_exponent;
extern double CRT_exponent;
extern double default_display_exponent;

#endif
